package jarvis.fs;

import org.apache.lucene.index.Term;

/**
 * Function: The comparableterm class whose score value is two integer
 * Comparison is consist of the comparison of value1 firstly and then the value2
 * @author Jarvis.Guo
 *
 */
public class TwoIntComparableTerm extends ComparableTerm {

	private int value1;
	private int value2;
	
	public TwoIntComparableTerm(Term term,int value1, int value2)
	{
		this.termText = term.text();
		this.value1 = value1;
		this.value2 = value2;
	}
	
	/* (non-Javadoc)
	 * @see jarvis.fs.ComparableTerm#compareTo(java.lang.Object)
	 */
	@Override
	public int compareTo(Object o) {
		TwoIntComparableTerm tic = (TwoIntComparableTerm) o;
		if(this.value1>tic.value1) return -1;
		if(this.value1<tic.value1) return 1;
		if(this.value1==tic.value1)
		{
			if(this.value2>tic.value2) return -1;
			if(this.value2<tic.value2) return 1;
		}
		return 0;
	}

	/* (non-Javadoc)
	 * @see jarvis.fs.ComparableTerm#valueString()
	 */
	@Override
	public String valueString() {
		return value1+","+value2;
	}

}
